<ui:composition 
	template="/resources/templates/template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">


	<ui:define name="principal">
	
	
			<h:form id="formPesquisar">
		
		<p:panel id="painelAcoesSuper" header="Listagem e Pesquisa de Pessoas">
		
			<ui:decorate template="/resources/templates/edit.xhtml">
				
				<ui:define name="label">
					Nome:
				</ui:define>
				
				<p:inputText id="nomePesquisa"
					value="#{manterPessoaMB.filtro.nome}"
					size="50" />
					
			</ui:decorate>
		
			<br />
		
			<p:commandButton id="botaoPesquisar"
			 				value="Pesquisar"
			 				update="formPesquisar:panelTabela"
			 				action="#{manterPessoaMB.pesquisarPessoas()}"
			 				ajax="true" />
			 				
		</p:panel>
		
		<br />
		
		<h:panelGroup id="panelTabela" >
			<h:panelGroup>
			
			<p:dataTable id="tabela" 
						value="#{manterPessoaMB.listaPessoas}"
						var="item" >
						
				<f:facet name="header">Resultados</f:facet>
			
				<p:column>
					<f:facet name="header">Nome</f:facet>
					<h:outputText value="#{item.nome}" />
				</p:column>
			
				<p:column>
					<f:facet name="header">Email</f:facet>
					<h:outputText value="#{item.email}" />
				</p:column>
			
				<p:column>
					<f:facet name="header">Data Cadastro</f:facet>
					<h:outputText value="#{item.dataNascimento}">
						<f:convertDateTime pattern="dd/MM/yyyy"/>
					</h:outputText>
				</p:column>
			
				<p:column>
					<p:commandLink id="editar"
								ajax="false"
								action="#{manterPessoaMB.comandoAlterar}" >
								
						<p:graphicImage value="/resources/img/editar-dados.png" title="alterar"  />
						
						<f:setPropertyActionListener target="#{item}" value="#{manterPessoaMB.pessoa}" />
								
					</p:commandLink>

					<p:spacer width="5" />
					
					<p:commandLink id="visualizar"
								ajax="false"
								action="#{manterPessoaMB.comandoVisualizar}" >
								
						<p:graphicImage value="/resources/img/pesquisar.png" title="visualizar"  />
						
						<f:setPropertyActionListener target="#{item}" value="#{manterPessoaMB.pessoa}" />
								
					</p:commandLink>
					
					<p:spacer width="5" />
					
					<p:commandLink id="excluir"
								ajax="true"
								update=":formPesquisar:panelTabela"
								action="#{manterPessoaMB.comandoExcluir}" >
								
						<p:graphicImage value="/resources/img/excluir.png" title="visualizar"  />
						
						<f:setPropertyActionListener target="#{item}" value="#{manterPessoaMB.pessoa}" />
								
					</p:commandLink>
				</p:column>
			
			</p:dataTable>
			
			</h:panelGroup>
		</h:panelGroup>
		
		</h:form>
	</ui:define>


</ui:composition>